import VariableLengthTableColumnSetter, { CodeSetterName as columnSetterName } from './VariableLengthTableColumnSetter';
// import TableField from '@ali-dayu/form-editor/lib/viewComponents/TableField';
import { CodeSetterName } from './CodeSetter';
import ArrayTableViewComponent from './components/ArrayTableViewComponent';

const widgetKey = "arrayTable";
// const widgetKey = "TableField";

const newConfig = {
  cfg: {
    copyEnable: true,
    dropToColumnEnable: false,
    category: 'advanced',
    componentName: 'arrayTable',
    name: '自增表格',
    description: '',
    icon: 'logo_table',
    setters: [
      {
        propName: "_id",
        setterName: CodeSetterName,
        props: { label: "表单编码" },
      },
      {
        propName: "enableAsFlowVariable",
        setterName: 'EnableAsFlowVariableSetter',
        props: { label: "是否启用变量" },
      },
      {
        propName: "label",
        setterName: "Input",
        props: {
          label: "标题",
          subLabel: "最多20字",
          maxLength: 20,
          validateMessage: {
            required: "标题不能为空",
          },
        },
      },
      /*
      {
        propName: "defaultLines",
        setterName: "InputNumber",
        props: {
          label: "表格默认行数",
          min: 0,
          max: 20,
        },
      },
      */
      {
        propName: "items",
        setterName: columnSetterName,
        props: {
          label: "列表项设置",
        },
      },
      {
        propName: "required",
        setterName: "Switch",
        props: {
          label: "必填",
        },
      },
    ],
    props: {
      label: "自增表格",
      required: false,
      enableAsFlowVariable: false,
      defaultLines: 3,
    },
  },
  extend: ArrayTableViewComponent,
};

/*
const newConfig = {
  cfg: {
    dropToTableEnable: false,
    isContainer: true,
    isTable: true,
    category: 'layout',
    componentName: 'TableField',
    name: '列表/表格',
    description: '',
    icon: 'logo_table',
    setters: [
      {
        propName: "_id",
        setterName: CodeSetterName,
        props: { label: "表单编码" },
      },
      {
        propName: "enableAsFlowVariable",
        setterName: 'EnableAsFlowVariableSetter',
        props: { label: "是否启用变量" },
      },
      {
        propName: 'label',
        setterName: 'Input',
        props: {
          label: '标题',
          subLabel: '最多20字',
          maxLength: 20,
          validateMessage: {
            required: '标题不能为空',
          },
        },
      },
      {
        propName: "defaultLines",
        setterName: "InputNumber",
        props: {
          label: "表格默认行数",
          min: 0,
          max: 20,
        },
      },
      /*
      {
        propName: 'actionName',
        setterName: 'Input',
        props: {
          label: '动作名称',
          maxLength: 20,
        },
      },
      {
        propName: 'tableViewMode',
        setterName: 'Radio',
        props: {
          label: '填写方式',
          options: [
            {
              label: '列表',
              value: 'list',
              image: '//gw.alicdn.com/tfs/TB1iK9leTM11u4jSZPxXXahcXXa-894-390.png',
            },
            {
              label: '表格',
              value: 'table',
              image: '//gw.alicdn.com/tfs/TB1S.tqOAY2gK0jSZFgXXc5OFXa-894-390.png',
            },
        ],
        },
      },
      * /
      {
        propName: "required",
        setterName: "Switch",
        props: {
          label: "必填",
        },
      },
    ],
    props: {
      label: '表格',
      actionName: '添加',
      tableViewMode: 'table',
    },
    children: [],
  },
  extend: TableField,
};
*/

const setting = {
  widget: {
    [widgetKey]: newConfig,
  },
  // setter: {},
  setter: {
    [columnSetterName]: {
      cfg: {
        setterName: columnSetterName,
        props: {
          // params: {
          //   multiple: true,
          // },
        },
      },
      extend: VariableLengthTableColumnSetter,
    },
  },
};

export default setting;
